.class public Lcom/zuiapps/suite/utils/font/FontUtil;
.super Ljava/lang/Object;
.source "FontUtil.java"


# direct methods
.method public constructor <init>()V
    .registers 1

    .prologue
    .line 13
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getFontHeight(Ljava/lang/String;FLandroid/graphics/Typeface;)I
    .registers 7
    .param p0, "str"    # Ljava/lang/String;
    .param p1, "fontSize"    # F
    .param p2, "typeface"    # Landroid/graphics/Typeface;

    .prologue
    .line 15
    if-eqz p0, :cond_a

    const-string v2, ""

    invoke-virtual {p0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_c

    .line 16
    :cond_a
    const-string p0, "0"

    .line 18
    :cond_c
    new-instance v0, Landroid/graphics/Paint;

    invoke-direct {v0}, Landroid/graphics/Paint;-><init>()V

    .line 19
    .local v0, "pFont":Landroid/graphics/Paint;
    new-instance v1, Landroid/graphics/Rect;

    invoke-direct {v1}, Landroid/graphics/Rect;-><init>()V

    .line 20
    .local v1, "rect":Landroid/graphics/Rect;
    invoke-virtual {v0, p1}, Landroid/graphics/Paint;->setTextSize(F)V

    .line 21
    if-eqz p2, :cond_1e

    .line 22
    invoke-virtual {v0, p2}, Landroid/graphics/Paint;->setTypeface(Landroid/graphics/Typeface;)Landroid/graphics/Typeface;

    .line 24
    :cond_1e
    const/4 v2, 0x0

    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v3

    invoke-virtual {v0, p0, v2, v3, v1}, Landroid/graphics/Paint;->getTextBounds(Ljava/lang/String;IILandroid/graphics/Rect;)V

    .line 25
    invoke-virtual {v1}, Landroid/graphics/Rect;->height()I

    move-result v2

    return v2
.end method

.method public static getFontWidth(Ljava/lang/String;FLandroid/graphics/Typeface;)I
    .registers 7
    .param p0, "str"    # Ljava/lang/String;
    .param p1, "fontSize"    # F
    .param p2, "typeface"    # Landroid/graphics/Typeface;

    .prologue
    .line 29
    if-eqz p0, :cond_a

    const-string v2, ""

    invoke-virtual {p0, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_c

    .line 30
    :cond_a
    const-string p0, "0"

    .line 32
    :cond_c
    new-instance v0, Landroid/graphics/Paint;

    invoke-direct {v0}, Landroid/graphics/Paint;-><init>()V

    .line 33
    .local v0, "pFont":Landroid/graphics/Paint;
    new-instance v1, Landroid/graphics/Rect;

    invoke-direct {v1}, Landroid/graphics/Rect;-><init>()V

    .line 34
    .local v1, "rect":Landroid/graphics/Rect;
    invoke-virtual {v0, p1}, Landroid/graphics/Paint;->setTextSize(F)V

    .line 35
    if-eqz p2, :cond_1e

    .line 36
    invoke-virtual {v0, p2}, Landroid/graphics/Paint;->setTypeface(Landroid/graphics/Typeface;)Landroid/graphics/Typeface;

    .line 38
    :cond_1e
    const/4 v2, 0x0

    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v3

    invoke-virtual {v0, p0, v2, v3, v1}, Landroid/graphics/Paint;->getTextBounds(Ljava/lang/String;IILandroid/graphics/Rect;)V

    .line 39
    invoke-virtual {v1}, Landroid/graphics/Rect;->width()I

    move-result v2

    add-int/lit8 v2, v2, 0xa

    return v2
.end method

.method public static px2sp(Landroid/content/Context;F)I
    .registers 5
    .param p0, "context"    # Landroid/content/Context;
    .param p1, "pxValue"    # F

    .prologue
    .line 51
    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/res/Resources;->getDisplayMetrics()Landroid/util/DisplayMetrics;

    move-result-object v1

    iget v0, v1, Landroid/util/DisplayMetrics;->scaledDensity:F

    .line 52
    .local v0, "fontScale":F
    div-float v1, p1, v0

    const/high16 v2, 0x3f000000

    add-float/2addr v1, v2

    float-to-int v1, v1

    return v1
.end method
